/**
 *
 *
 */
package com.fw.timesheet.dao;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.fw.timesheet.model.GroupAccess;



/**
 * @author sigit <br>
 * @version 1.0 <br>
 * Application : timesheet <br>
 * Copyright (c) fastwire-group 2012 <br>
 * <br>
 */
public class GroupAccessDAO extends BaseDAO {

private static final Log log = LogFactory.getLog(GroupAccessDAO.class);
	
	public void save(GroupAccess transientInstance) {
		log.debug("saving GroupAccess instance");
		try {
			getHibernateTemplate().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}
	
	public void saveOrUpdate(Object transientInstance) {
		log.debug("saving GroupAccess instance");
	    try {
	    	GroupAccess groupAccess = (GroupAccess) getHibernateTemplate().merge(transientInstance);
	        getHibernateTemplate().saveOrUpdate(groupAccess);
	        log.debug("save successful");
	    } catch (RuntimeException re) {
	    	log.error("save failed", re);
	    	throw re;
	    }
	}

	public void delete(GroupAccess persistentInstance) {
		log.debug("deleting GroupAccess instance");
		try {
			getHibernateTemplate().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public GroupAccess findById(java.lang.Long id) {
		log.debug("getting GroupAccess instance with id: " + id);
		try {
			GroupAccess instance = (GroupAccess) getHibernateTemplate()
					.get("com.fw.timesheet.model.GroupAccess", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByExample(GroupAccess instance) {
		log.debug("finding GroupAccess instance by example");
		try {
			List results = getHibernateTemplate().findByExample(instance);
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}

	public List findByProperty(String propertyName, Object value) {
		log.debug("finding GroupAccess instance with property: " + propertyName
				+ ", value: " + value);
		try {
			String queryString = "from GroupAccess as model where model."
					+ propertyName + "= ?";
			return getHibernateTemplate().find(queryString, value);
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}
}
